/*     */ package com.zimbra.qa.unittest;
/*     */ 
/*     */ import com.zimbra.client.ZFolder;
/*     */ import com.zimbra.client.ZFolder.Color;
/*     */ import com.zimbra.client.ZFolder.View;
/*     */ import com.zimbra.client.ZGrant.GranteeType;
/*     */ import com.zimbra.client.ZMailbox;
/*     */ import com.zimbra.client.ZMailbox.OwnerBy;
/*     */ import com.zimbra.client.ZMailbox.SharedItemBy;
/*     */ import com.zimbra.client.ZMountpoint;
/*     */ import com.zimbra.client.ZSearchParams;
/*     */ import com.zimbra.client.ZSearchResult;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import junit.framework.TestCase;
/*     */ import org.junit.After;
/*     */ import org.junit.Before;
/*     */ import org.junit.Test;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class TestSearchJunkTrash
/*     */   extends TestCase
/*     */ {
/*     */   private static final String USER_NAME = "junktrashuser1";
/*     */   private static final String REMOTE_USER_NAME = "junktrashuser2";
/*     */   private static ZMailbox mbox;
/*     */   private static ZMailbox remote_mbox;
/*     */   private static ZFolder folder;
/*     */   private static ZMountpoint mPoint;
/*     */   
/*     */   @Before
/*     */   public void setUp()
/*     */     throws Exception
/*     */   {
/*  47 */     TestUtil.createAccount("junktrashuser1");
/*  48 */     TestUtil.createAccount("junktrashuser2");
/*  49 */     mbox = TestUtil.getZMailbox("junktrashuser1");
/*  50 */     remote_mbox = TestUtil.getZMailbox("junktrashuser2");
/*  51 */     folder = remote_mbox.createFolder("1", "my shared folder", ZFolder.View.message, null, null, null);
/*  52 */     remote_mbox.modifyFolderGrant(folder.getId(), ZGrant.GranteeType.usr, "junktrashuser1", "r", null);
/*  53 */     mPoint = mbox.createMountpoint("1", folder.getName(), ZFolder.View.message, ZFolder.Color.BLUE, null, ZMailbox.OwnerBy.BY_NAME, "junktrashuser2", ZMailbox.SharedItemBy.BY_ID, folder.getId(), false);
/*     */     
/*  55 */     Map<String, Object> prefs = new HashMap();
/*  56 */     prefs.put("zimbraPrefIncludeSharedItemsInSearch", "TRUE");
/*  57 */     mbox.modifyPrefs(prefs);
/*  58 */     TestUtil.addMessage(mbox, "junk message 1", "4");
/*  59 */     TestUtil.addMessage(mbox, "junk message 2", "4");
/*  60 */     TestUtil.addMessage(mbox, "a trash message", "3");
/*     */   }
/*     */   
/*     */   @After
/*     */   public void tearDown() throws Exception
/*     */   {
/*  66 */     TestUtil.deleteAccount("junktrashuser1");
/*  67 */     TestUtil.deleteAccount("junktrashuser2");
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testJunk() throws ServiceException {
/*  72 */     ZSearchParams params = new ZSearchParams(String.format("(in:junk) (inid:%s OR is:local)", new Object[] { folder.getId() }));
/*  73 */     ZSearchResult results = mbox.search(params);
/*  74 */     assertEquals(2, results.getHits().size());
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testTrash() throws ServiceException {
/*  79 */     ZSearchParams params = new ZSearchParams(String.format("(in:trash) (inid:%s OR is:local)", new Object[] { folder.getId() }));
/*  80 */     ZSearchResult results = mbox.search(params);
/*  81 */     assertEquals(1, results.getHits().size());
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testTrashOrJunk() throws ServiceException {
/*  86 */     ZSearchParams params = new ZSearchParams(String.format("(in:trash OR in:junk) (inid:%s OR is:local)", new Object[] { folder.getId() }));
/*  87 */     ZSearchResult results = mbox.search(params);
/*  88 */     assertEquals(3, results.getHits().size());
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testTrashOrNotJunk() throws ServiceException
/*     */   {
/*  94 */     ZSearchParams params = new ZSearchParams(String.format("(in:trash OR NOT in:junk) (inid:%s OR is:local)", new Object[] { folder.getId() }));
/*  95 */     ZSearchResult results = mbox.search(params);
/*  96 */     assertEquals(1, results.getHits().size());
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testNotNotTrashOrJunk() throws ServiceException
/*     */   {
/* 102 */     ZSearchParams params = new ZSearchParams(String.format("(NOT(in:trash OR NOT in:junk)) (inid:%s OR is:local)", new Object[] { folder.getId() }));
/* 103 */     ZSearchResult results = mbox.search(params);
/* 104 */     assertEquals(2, results.getHits().size());
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestSearchJunkTrash.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */